DBE listView callback being called recurrently

Hi all,

I'm trying to put in place a simple mechanism for selecting a single checkbox from a listView, clearing any previously selected checkbox via a callback.

The code of the callback is the following:

void fnSelectSrcAttr(DBE calledfrom, int i){
    int iCount
 
        bool isCheck=getCheck(calledfrom,i)
 
        print sizeof(srcAttributes) " "
        print i "\n"
        
        if (isCheck) {
                for (iCount=0;iCount<=sizeof(srcAttributes)-2;iCount++){
                        if (iCount!=i){
                                setCheck(srcModAttrList,iCount,false)
                        }
                }
        }
}

 


srcAttributes is the array of strings used to create the listView.

Everithing works fine on the first selection. When a second attempt to select another checkbox is done, DOORS crashes (not responding), and seems that the callback is called againg when changing the state of the original checkbox. On this recurrent call, the output of

 

print sizeof(srcAttributes) " "

returns 0 before crashing.

Any idea on how to avoid such behavior?
My client version is 9.3.0.7


SystemAdmin - Fri Oct 19 11:19:12 EDT 2012

Re: DBE listView callback being called recurrently
Mathias Mamsch - Sun Oct 21 06:16:32 EDT 2012

Well when you modify the DBE element inside its own 'on-change' callback you need to introduce a global variable to avoid an endless loop:
 

bool bInFunction = false 
 
void myCallback (DBE) {
   if (bInFunction == true) return // avoid endless loop 
 
   bInFunction = true 
    // ... modify element here ...
   bInFunction = false 
}

 


Hope this helps, regards, Mathias

 

 


Mathias Mamsch, IT-QBase GmbH, Consultant for Requirement Engineering and D00RS

 

Re: DBE listView callback being called recurrently
SystemAdmin - Mon Oct 22 07:34:30 EDT 2012

Thanks Mathias!
A semaphore scheme, as you proposed, solved the problem.